/**
 * @author 谭
 * 书路由
 */
"use strict";
const express = require('express');

const router = express.Router();

const expressJoi = require('@escook/express-joi');

const { regAddBooks, regGetBooks, regDelBooks, regAddBooksClassify, regRecordBooks } = require('../../schema/books/books');

const books = require('../../handle/books/books');

const { getAllBooks, getAllBooksRecord, judgeUserBooksRecord, judgeBooksIsNull } = require('../../middle/books/books');

/*
    录入书的分类标签
 */
router.post('/addBooksClassIfy',expressJoi(regAddBooksClassify),books.addBooksClassIfy);

/*
    获取书的分类标签
 */
router.get('/getBooksClassIfy',books.getBooksClassIfy);

/*
    删除书的分类标签
 */
router.get('/delBooksClassify/:id',expressJoi(regDelBooks),books.delBooksClassify);

/*
    录入书籍
 */
router.post('/addBooks',expressJoi(regAddBooks),books.addBooks);

/*
    获取书籍
 */
router.post('/getBooks',expressJoi(regGetBooks),getAllBooks,books.getBooks);

/*
    删除书籍
 */
router.get('/delBooks/:id',expressJoi(regDelBooks),books.delBooks);

/*
    借阅书
 */
router.get('/recordBooks/:booksId',expressJoi(regRecordBooks),judgeBooksIsNull,books.recordBooks);

/*
    获取所有的借阅记录
 */
router.post('/getAllBooksRecord',expressJoi(regGetBooks),getAllBooksRecord,books.getAllBooksRecord);


/*
    获取自己的借阅记录
 */
router.get('/getMyBooksRecord',books.getMyBooksRecord);

/*
    还书
 */
router.get('/judgeUserBooksRecord/:recordId',expressJoi(regRecordBooks),judgeUserBooksRecord,books.UserBooksRecord)

module.exports = router;
